﻿using EPiServer.Core;
using EPiServer.DataAbstraction;
using PageTypeBuilder;
using TemplateFoundation.Core;
using TemplateFoundation.Tags;

namespace TemplateFoundation.PageTypes
{
    /// <summary>
    /// Base class for page types used to list pages based on tags
    /// </summary>
    public abstract class ArticleTagListingPageBase : ArticleListingPageBase
    {
        /// <summary>
        /// Gets or sets the number of pages tagged with this tag
        /// </summary>
        [PageTypeProperty(
            UniqueValuePerLanguage = false,
            DefaultValueType = DefaultValueType.Value,
            DefaultValue = "0",
            DisplayInEditMode = false,
            Type = typeof (PropertyNumber))]
        public virtual int PageCount { get; set; }

        /// <summary>
        /// Gets the articles of the current listing
        /// </summary>
        /// <value></value>
        public override PageDataCollection Articles
        {
            get { return PageFactory.Instance.GetArticlesByTag(new Tag(PageName)); }
        }
    }
}